package com.flysky.model.finance;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;

@Entity
@Table(name="flysky_finance_smalltype")
public class SmallTypeHbmModel implements Serializable{

	/**
	 * @author kp18166
	 */
	private static final long serialVersionUID = 1L;

	private int type_id;
	
	private String type_name;
	
	private BigTypeHbmModel bigType;

	@Id
	@GeneratedValue(generator = "smallTypeGenerator")    
	@GenericGenerator(name = "smallTypeGenerator", strategy = "increment")
	@Column(name="type_id")
	public int getType_id() {
		return type_id;
	}

	public void setType_id(int type_id) {
		this.type_id = type_id;
	}

	@Column(name="type_name")
	public String getType_name() {
		return type_name;
	}

	public void setType_name(String type_name) {
		this.type_name = type_name;
	}
	
	@ManyToOne(targetEntity=BigTypeHbmModel.class,cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH})
	@JoinColumn(name="bigtype" )
	public BigTypeHbmModel getBigType() {
		return bigType;
	}

	public void setBigType(BigTypeHbmModel bigType) {
		this.bigType = bigType;
	}

	@Override
	public String toString() {
		return "SmallTypeHbmModel [type_id=" + type_id + ", type_name="
				+ type_name + "]";
	}

	@Override
	public boolean equals(Object obj) {
		if(null == obj){
			return false;
		}
		if(!(obj instanceof SmallTypeHbmModel)){
			return false;
		}
		SmallTypeHbmModel smallType = (SmallTypeHbmModel)obj;
		if(this.getType_id() == smallType.getType_id()){
			return true;
		}else{
			return false;
		}
	}

}
